<html>
<head>
    <link href="style.css" rel="stylesheet"/>
    <%
        String paragraf = request.getParameter("para");
        String learn = request.getParameter("id");
    %>
    <script type="text/javascript" language="javascript">
        function validasi() {
            var kata = document.getElementById("word").value;
            var arti = document.getElementById("arti").value;
            var jenis = document.getElementById("tipeword").value;
            var cth = document.getElementById("contoh").value;
            var paragraf = document.getElementById("paragraf").value;
            var wordstem = document.getElementById("wordstem").value;


            if (kata == null || kata == "") {
                err.innerHTML = "Please insert the word!";
                return false;
            }
            else if (arti == null || arti == "") {
                err.innerHTML = "Please insert the definition!";
                return false;
            }
            else if (jenis == null || jenis == "") {
                err.innerHTML = "Please insert the word's type!";
                return false;
            }
            else if (cth == null || cth == "") {
                err.innerHTML = "Please insert the example!";
                return false;
            }
            else if (wordstem == null || wordstem == "") {
                err.innerHTML = "Please insert the word stem!";
                return false;
            }
            else if (kata.indexOf(" ") >= 1) {
                err.innerHTML = "Please insert the word!";
                return false;
            }

            else {
                return true;
            }
        }

    </script>
</head>
<body>
<div id="popup-header">
    <h2>Add New Word</h2>
</div>
<form method="post" action="doAddNewWord.jsp" onsubmit="return validasi()">
    <table id="word1">
        <input type="hidden" name="learn" id="learn" value="<%=learn%>">

        <tr>
            <td>Word</td>
            <td>:</td>
            <td><input type="text" name="word" id="word"></td>
        </tr>
        <tr>
            <td>Definition</td>
            <td>:</td>
            <td><textarea name="arti" id="arti"></textarea></td>

        </tr>
        <tr>
            <td>Image</td>
            <td>:</td>
            <td><input type="text" name="image" id="image"></td>
        </tr>
        <tr>
            <td>Part Of Speech</td>
            <td>:</td>
            <td><input type="text" name="tipeword" id="tipeword"></td>
        </tr>
        <tr>
            <td>Word Stem</td>
            <td>:</td>
            <td><input type="text" name="wordstem" id="wordstem"></td>
        </tr>
        <tr>
            <td>Example</td>
            <td>:</td>
            <td><textarea name="contoh" id="contoh"></textarea></td>
        </tr>

        <tr id="warning">
            <td colspan="3">
                <div id="err"></div>
            </td>
        </tr>
        <tr align="right">
            <td colspan="3">
                <div class="btn-fld">
                    <button type="reset">Reset</button>
                    <button type="submit">Save</button>

                </div>
            </td>
        </tr>

    </table>
</form>


</body>
</html>